package email

import (
	"awesomeProject1/push/plugin"
)

type EmailPlugin struct {
	Enabled bool
}

func (p *EmailPlugin) SendMessage(info plugin.MessageInfo) error {
	// 调用不同邮件服务实现发送邮件
	//TODO 邮件服务配置应从配置中获取
	emailService := NewEmailService(plugin.SmtpServer, plugin.SmtpPort, plugin.Username, plugin.Password)

	err := emailService.SendEmail(info)
	if err != nil {
		panic("发送失败")
	}

	return nil
}

func (p *EmailPlugin) IsEnabled() bool {
	p.Enabled = true
	return p.Enabled
}
